#ifndef SYNC_QUEUE_HH
#define SYNC_QUEUE_HH

#include<vector>
#include "uThread.hh"
#include <iostream>

class Sync_queue {
private:
	int id,num;
	std::vector<uThread*> threads;
public:
	Sync_queue(int id, int num) : id(id), num(num)  {};
	
	void add_thread(uThread *t) {
		threads.push_back(t);
	};
	
	void remove_thread(uThread *t) {
		std::vector<uThread*>::iterator it=threads.begin();
		for(;it!=threads.end();++it) {
			if(*it==t) {
				threads.erase(it);
				break;
			}
		}
	}
	
	int get_id() const {
		return id;
	}
	
	int get_num() const {
		return num;
	};
	
	int get_size() const {
		return threads.size();
	};
	
	std::vector<uThread*>::iterator begin() {
		return threads.begin();
	};
	
	std::vector<uThread*>::iterator end() {
		return threads.end();
	};
	
	void print_vectors() const {
		for(std::vector<uThread*>::const_iterator it=threads.begin(); it!=threads.end(); ++it)
			std::cout << "Thread:" << (*it)->get_id() << ", status:" << (*it)->get_state() << std::endl;
		std::cout << std::endl;
	}
};
#endif